package demo.day10;

import demo.classuse.Student;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/7/28-07-28-15:15
 * @Description：demo.day10    匿名代码块
 */
public class anonymity_use{
    int a = 1;
    //匿名代码块一般用于赋值 ，
    //构造器调用多少次，匿名代码块就会调用多少次
    {
        a = 5;
        System.out.println("anonymity_use.instance initializer");
    }
    //静态代码块优先于匿名代码块执行，且静态代码块只执行一次
    static {
        System.out.println("static.anonymity_use.static initializer");
    }
    public anonymity_use(){
        System.out.println("a = " + a);
    }
    public static void main(String[] args) {
        anonymity_use via = new anonymity_use();
        anonymity_use via2 = new anonymity_use();
        System.out.println(via.a);
    }
    public void print(){
        System.out.println("anonymity_use.print  + " + a);
    }
}
